<template>
	<view>
		<!-- <view class="banner" v-if="info.image"><image class="banner-img" :src="info.image"></image></view> -->
		<view class="article-meta">
			<!-- <text class="article-author f_32 c_0" >
				{{ info.title }}
			</text> -->
		
		<!-- 	<text class="article-text">发布时间：{{ $util.timeStampTurnTime(info.createtime) }}</text> -->
			<text class="article-time  iconfont1 iconeye" style="font-size: 25rpx;line-height: 50rpx;" v-if="info.click > 0">&nbsp;{{ info.click > 10000 ? info.click / 10000 + '万' : info.click }}</text>
		</view>
		<view class="article-content"><rich-text :nodes="htmlNodes"></rich-text>
		<view class="c_blue f_28" @click="fuzhi" v-if='info.id==82'>复制链接</view>
		</view>
		
		<view class="adimg" v-if='info.id==82'>
			
			<image src="@/static/image/ad1.png" mode="widthFix"></image>
			<image src="@/static/image/ad2.png" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
import http from 'common/js/http.js';
import htmlParser from '@/common/js/html-parser';
export default {
	data() {
		return {
			articleId: '',
			info: {},
			htmlNodes: '',
			lastTitle: '',
			nextTitle: '',
			lastId: '',
			nextId: ''
		};
	},
	onLoad(event) {
		this.articleId = event.id;
		this.getDetail(event.id);
		
	},
	mixins: [http],
	methods: {
		fuzhi(){
			uni.setClipboardData({
			             data: 'http://jhthcnxq.jszwfw.gov.cn/',
			             success() {
			                uni.showToast({
			                	title:'复制成功'
			                })
			             },
			             fail() {
			                 console.log('复制失败');
			             }
			         });
		},
		getDetail(id) {
			var data = {
				id: id,
				town_id:1
			};
			this.sendRequest({
				url: 'cun/articledetail',
				data: data,
				success: res => {
					if (res.code>0) {
						 res.data.content =  res.data.content.replace(/<table class="table table-bordered">/g, '<table style="width:100%;border-collapse:collapse;">');
						 res.data.content =  res.data.content.replace(/<td>/g, '<td style="border:1px solid #ebebeb;">');
						res.data.content =  res.data.content.replace(/<o:p>/g, '');
						this.info = res.data;
						
						this.htmlNodes = htmlParser(res.data.content);
						uni.setNavigationBarTitle({
							title: this.info.title
						});
						if(id==82){
							uni.showModal({
								title:'提示',
								content:'请点击确定复制网址到浏览器查看',
								success:e=>{
									if(e.confirm){
										   uni.setClipboardData({
										                data: 'http://jhthcnxq.jszwfw.gov.cn/',
										                success() {
										                   uni.showToast({
										                   	title:'复制成功'
										                   })
										                },
										                fail() {
										                    console.log('复制失败');
										                }
										            });
													// setTimeout(()=>{
													// 	uni.redirectTo({
													// 		url:'/pages/order/index'
													// 	})
													// },2000)
									}
								}
							})
						}
						if(id==94){
							uni.showModal({
								title:'提示',
								content:'请点击确定复制网址到浏览器查看',
								success:e=>{
									if(e.confirm){
										   uni.setClipboardData({
										                data: 'http://mzt.jiangsu.gov.cn/art/2021/9/6/art_78620_10001272.html',
										                success() {
										                   uni.showToast({
										                   	title:'复制成功'
										                   })
										                },
										                fail() {
										                    console.log('复制失败');
										                }
										            });
													// setTimeout(()=>{
													// 	uni.redirectTo({
													// 		url:'/pages/order/index'
													// 	})
													// },2000)
									}
								}
							})
						}
					}
				}
			});
		},
		setArticleClick(id) {
			var data = {
				article_id: id
			};
			this.sendRequest({
				url: 'System.Article.setArticleClick',
				data: data,
				success: res => {}
			});
		},
		getLast() {
			// 上一篇
			var data = {
				order: 'public_time asc',
				condition: JSON.stringify({
					article_id: ['gt', this.articleId]
				})
			};
			this.sendRequest({
				url: 'System.Article.articleFirst',
				data: data,
				success: res => {
					this.lastTitle = res.data.title;
					this.lastId = res.data.article_id;
				}
			});
		},
		getNext() {
			// 下一篇
			var data = {
				order: 'public_time desc',
				condition: JSON.stringify({
					article_id: ['lt', this.articleId]
				})
			};
			this.sendRequest({
				url: 'System.Article.articleFirst',
				data: data,
				success: res => {
					this.nextTitle = res.data.title;
					this.nextId = res.data.article_id;
				}
			});
		},
		goDetail(id) {
			uni.redirectTo({
				url: 'detail?article_id=' + id
			});
			
		}
	}
};
</script>

<style lang="scss">
	.adimg{
		width: 90%;
		margin: 0 auto;
		image{
			width: 100%;
		}
	}
	
	page{
		background:#fff;
	}
.banner {
	height: 360rpx;
	overflow: hidden;
	position: relative;
	background-color: #fff
}

.banner-img {
	width: 100%;
}

.article-meta {
	padding: 20rpx 40rpx;
	display: flex;
	flex-direction: row;
	justify-content: flex-start;
	color: #333;
}

.article-text {
	font-size:28rpx;
	line-height: 50rpx;
	margin: 0 20rpx;
}

.article-author,
.article-time {
	font-size: 28rpx;
}

.article-content {
	padding: 0 30rpx;
	overflow: hidden;
	font-size: 28rpx;
	margin-bottom: 30rpx;
	padding-bottom: 30rpx;
}
.titles {
	// display: flex;
	justify-content: space-between;
	padding-left:20rpx;
	padding-right:20rpx;
	margin-bottom: 100rpx;
	view {
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.float-right {
		text-align: right;
	}
	.ns-padding-left{
		padding-left: 0 !important;
	}
}

</style>
